import 'package:flutter/material.dart';
import 'package:flutter_wanandroid_ohos/common/index.dart';
import 'package:flutter_wanandroid_ohos/pages/simple/load_container/controller.dart';
import 'package:getx_scaffold_ohos/getx_scaffold_ohos.dart';

class LoadContainerPage extends GetView<LoadContainerController> {
  const LoadContainerPage({super.key});

  Widget _buildView() {
    return <Widget>[
      TextX.titleLarge('Page contents'),
      ButtonX(
        'Show Load Error',
        onPressed: () => controller.onError(),
      ).width(double.infinity).padding(top: 30.h, horizontal: 50.w),
      ButtonX(
        'Show Load Empty',
        onPressed: () => controller.onEmpty(),
      ).width(double.infinity).padding(top: 10.h, horizontal: 50.w)
    ].toColumn(mainAxisSize: MainAxisSize.min).center();
  }

  @override
  Widget build(BuildContext context) {
    return GetBuilder<LoadContainerController>(
        init: LoadContainerController(),
        id: 'loadContainer',
        builder: (_) {
          return Scaffold(
            appBar:
                AppBar(title: Text(TextKey.jiZaiRongQiZuJian.tr), elevation: 1),
            body: SafeArea(
              child: LoadContainer(
                controller: controller.loadController!,
                onReLoad: controller.onLoad,
                child: _buildView(),
              ),
            ),
          );
        });
  }
}
